#银行系统
#预存账户信息
Account=[{"卡号":1,"密码":123,"金额":12000},{"卡号":2,"密码":124,"金额":10000},{"卡号":3,"密码":234,"金额":15000}]
#定义输出函数
def ShowMoney(Account):
    print("{0:<10} {1:<15}".format("账户金额为：","金额"))
#登录界面
print("="*15,"欢迎来到自助存取系统","="*15)
ac1={}
ac1["卡号"]=input("请输入卡号信息：")
ac1["密码"]=input("请输入卡号密码：")
#帐号密码信息比对正确则进入系统操作界面
for i in range(len(Account)):
    #账户密码遍历
    ac2={}
    ac2["卡号"]=Account[i]["卡号"]
    ac2["密码"]=Account[i]["密码"]
    #账户密码比对
    if ac2==ac1:
        #银行操作界面
        while  True:
            print("="*15,"自助存取系统","="*15)
            print("{0:1} {1:13} {2:15}".format(" ","1. 查看账户金额","2. 取款"))
            print("{0:1} {1:13} {2:15}".format(" ","3. 存款","4. 退出系统"))
            print("="*40)
            key = input("请输入对应的选择：")
            if key == "1":
                print("="*12," 查看账户金额","="*14)
                ShowMoney(Account[i]["金额"])
                input("按回车键继续：")
            if key == "2":
                print("="*12," 取款","="*14)
                BaseMoney=int(Account[i]["金额"])
                DrawMoney=int(input("需要取款金额："))
                if BaseMoney-DrawMoney>=0:
                    Account[i]["金额"]=BaseMoney-DrawMoney
                    ShowMoney(Account[i]["金额"])
                    input("按回车键继续：")
                else:
                    print("账户金额不足，请重新确认")
                    break    
            if key == "3":
                print("="*12," 存款","="*14)
                BaseMoney=int(Account[i]["金额"])
                SaveMoney=int(input("需要存款金额："))
                Account[i]["金额"]=BaseMoney+SaveMoney
                ShowMoney(Account[i]["金额"])
                input("按回车键继续：")
            if key == "4":
                print("="*12," 欢迎下次光临","="*14)
                break
    else:
        break
print("="*12," 对不起，您输入的账户或密码错误","="*14)

